package com.karry.yl.web.mbassessment;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.karry.commons.PDFGenerator;
import com.karry.commons.base.SuperController;
import com.karry.commons.util.TimeUtil;
import com.karry.commons.vo.LayTableResponse;
import com.karry.yl.domain.assessment.MbAssessRecords;
import com.karry.yl.service.mbassessment.MbAssessRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 民办能力评估Controller
 */
@Controller
@RequestMapping("/mbAssessRecords")
public class MbAssessRecordsController extends SuperController {

    @Autowired
    private MbAssessRecordsService assessRecordsService;
    /**
     * 到列表页
     *
     * @return
     */
    @RequestMapping
    public String listUI() {
        return "mbassessment/list";
    }


    @RequestMapping("/list")
    @ResponseBody
    public LayTableResponse listUI(int page, int limit,String elderlyName, Integer rs) {
        Wrapper<MbAssessRecords> recordsWrapper=new EntityWrapper<MbAssessRecords>().eq("orgId", currentUser.getOrgId()).orderBy("createdTime",false);
        if(!StringUtils.isEmpty(elderlyName)){
            recordsWrapper.like("elderlyName",elderlyName);
        }
        if(!StringUtils.isEmpty(rs)){
            recordsWrapper.eq("rs",rs);
        }
        Page<MbAssessRecords> assessRecordsPage = assessRecordsService.selectPage(new Page<MbAssessRecords>(page, limit), recordsWrapper);
        return new LayTableResponse(assessRecordsPage.getRecords(), assessRecordsPage.getTotal());
    }

}
